/* matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
/* NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
window.matchMedia = window.matchMedia || (function(e, f) {
    var c, a = e.documentElement, b = a.firstElementChild || a.firstChild, d = e.createElement("body"), g = e.createElement("div");
    g.id = "mq-test-1";
    g.style.cssText = "position:absolute;top:-100em";
    d.style.background = "none";
    d.appendChild(g);
    return function(h) {
        g.innerHTML = '&shy;<style media="' + h + '"> #mq-test-1 { width: 42px; }</style>';
        a.insertBefore(d, b);
        c = g.offsetWidth === 42;
        a.removeChild(d);
        return{matches: c, media: h}
    }
}(document));
/* Respond.js v1.3.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs  */
(function(e) {
    var t = {};
    e.respond = t;
    t.update = function() {
    };
    t.mediaQueriesSupported = e.matchMedia && e.matchMedia("only all").matches;
    if (t.mediaQueriesSupported) {
        return
    }
    var x = e.document, s = x.documentElement, i = [], k = [], q = [], o = {}, h = 30, f = x.getElementsByTagName("head")[0] || s, g = x.getElementsByTagName("base")[0], b = f.getElementsByTagName("link"), d = [], a = function() {
        for (var B = 0; B < b.length; B++) {
            var A = b[B], z = A.href, C = A.media, y = A.rel && A.rel.toLowerCase() === "stylesheet";
            if (!!z && y && !o[z]) {
                if (A.styleSheet && A.styleSheet.rawCssText) {
                    m(A.styleSheet.rawCssText, z, C);
                    o[z] = true
                } else {
                    if ((!/^([a-zA-Z:]*\/\/)/.test(z) && !g) || z.replace(RegExp.$1, "").split("/")[0] === e.location.host) {
                        d.push({href: z, media: C})
                    }
                }
            }
        }
        v()
    }, v = function() {
        if (d.length) {
            var y = d.shift();
            n(y.href, function(z) {
                m(z, y.href, y.media);
                o[y.href] = true;
                e.setTimeout(function() {
                    v()
                }, 0)
            })
        }
    }, m = function(J, y, A) {
        var H = J.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi), K = H && H.length || 0;
        y = y.substring(0, y.lastIndexOf("/"));
        var z = function(L) {
            return L.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, "$1" + y + "$2$3")
        }, B = !K && A;
        if (y.length) {
            y += "/"
        }
        if (B) {
            K = 1
        }
        for (var E = 0; E < K; E++) {
            var F, G, C, I;
            if (B) {
                F = A;
                k.push(z(J))
            } else {
                F = H[E].match(/@media *([^\{]+)\{([\S\s]+?)$/) && RegExp.$1;
                k.push(RegExp.$2 && z(RegExp.$2))
            }
            C = F.split(",");
            I = C.length;
            for (var D = 0; D < I; D++) {
                G = C[D];
                i.push({media: G.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/) && RegExp.$2 || "all", rules: k.length - 1, hasquery: G.indexOf("(") > -1, minw: G.match(/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/) && parseFloat(RegExp.$1) + (RegExp.$2 || ""), maxw: G.match(/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/) && parseFloat(RegExp.$1) + (RegExp.$2 || "")})
            }
        }
        j()
    }, l, r, w = function() {
        var A, B = x.createElement("div"), y = x.body, z = false;
        B.style.cssText = "position:absolute;font-size:1em;width:1em";
        if (!y) {
            y = z = x.createElement("body");
            y.style.background = "none"
        }
        y.appendChild(B);
        s.insertBefore(y, s.firstChild);
        A = B.offsetWidth;
        if (z) {
            s.removeChild(y)
        } else {
            y.removeChild(B)
        }
        A = p = parseFloat(A);
        return A
    }, p, j = function(K) {
        var P = "clientWidth", B = s[P], z = x.compatMode === "CSS1Compat" && B || x.body[P] || B, N = {}, O = b[b.length - 1], A = (new Date()).getTime();
        if (K && l && A - l < h) {
            e.clearTimeout(r);
            r = e.setTimeout(j, h);
            return
        } else {
            l = A
        }
        for (var I in i) {
            if (i.hasOwnProperty(I)) {
                var L = i[I], E = L.minw, H = L.maxw, J = E === null, M = H === null, y = "em";
                if (!!E) {
                    E = parseFloat(E) * (E.indexOf(y) > -1 ? (p || w()) : 1)
                }
                if (!!H) {
                    H = parseFloat(H) * (H.indexOf(y) > -1 ? (p || w()) : 1)
                }
                if (!L.hasquery || (!J || !M) && (J || z >= E) && (M || z <= H)) {
                    if (!N[L.media]) {
                        N[L.media] = []
                    }
                    N[L.media].push(k[L.rules])
                }
            }
        }
        for (var G in q) {
            if (q.hasOwnProperty(G)) {
                if (q[G] && q[G].parentNode === f) {
                    f.removeChild(q[G])
                }
            }
        }
        for (var F in N) {
            if (N.hasOwnProperty(F)) {
                var D = x.createElement("style"), C = N[F].join("\n");
                D.type = "text/css";
                D.media = F;
                f.insertBefore(D, O.nextSibling);
                if (D.styleSheet) {
                    D.styleSheet.cssText = C
                } else {
                    D.appendChild(x.createTextNode(C))
                }
                q.push(D)
            }
        }
    }, n = function(y, A) {
        var z = c();
        if (!z) {
            return
        }
        z.open("GET", y, true);
        z.onreadystatechange = function() {
            if (z.readyState !== 4 || z.status !== 200 && z.status !== 304) {
                return
            }
            A(z.responseText)
        };
        if (z.readyState === 4) {
            return
        }
        z.send(null)
    }, c = (function() {
        var y = false;
        try {
            y = new e.XMLHttpRequest()
        } catch (z) {
            y = new e.ActiveXObject("Microsoft.XMLHTTP")
        }
        return function() {
            return y
        }
    })();
    a();
    t.update = a;
    function u() {
        j(true)
    }
    if (e.addEventListener) {
        e.addEventListener("resize", u, false)
    } else {
        if (e.attachEvent) {
            e.attachEvent("onresize", u)
        }
    }
})(this);
